package com.example.springaop.Aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class MyAspectDemo {
    @Around("@annotation(com.example.springaop.Aspect.MyAspect)")
    public Object recordTime(ProceedingJoinPoint pjp){
        log.info("目标方法执行前...");
        Object result = null;
        try{
            result=pjp.proceed();
        }catch (Throwable e){
            log.error("目标方法出错...");
        }
        log.info("目标方法执行后...");
        return result;
    }
}
